package com.game.action;

import com.game.logic.map.PVPService;
import com.game.logic.map.WordMap;
import com.xs.action.annotate.ActionController;
import com.xs.build.server.websocket.channel.ClientManager;
import lombok.Synchronized;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/// 6-地图操作
@RestController
@RequestMapping("/map")
@ActionController(value = 6, name = "地图")
public class MapAction {
    /// 校验是否在地图中
    @GetMapping("/check")
    public boolean check(
            Integer anchorInfoId
    ) {
        return WordMap.check(anchorInfoId);
    }

    /// 1.加入地图或寻宝
    @Synchronized
    @GetMapping("/joinMap")
    public void joinMap(
            Integer anchorInfoId,
            Integer mapId ,
            Integer level,
            String maxLevelRolesId
    ) {
        WordMap.joinMap(anchorInfoId, mapId, level, ClientManager.clientIdMap.get(anchorInfoId.toString()), maxLevelRolesId);
    }

    @Synchronized
    @GetMapping("/leave")
    public void leave(
            Integer anchorInfoId
    ) {
        WordMap.leave(anchorInfoId);
    }

    /// 2.发起战斗
    @GetMapping("/startBattle")
    public void startBattle(Integer anchorInfoId1, Integer anchorInfoId2) {
        PVPService.startBattle(anchorInfoId1, anchorInfoId2);
    }
}
